<style>
    .subAuths {
        margin:5px 0 5px 15px;
    }
</style>
<div class="modal-dialog" role="document" style="width:800px;">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title" id="exampleModalLabel">权限设置 - {$role.name}</h4>
        </div>
        <form style="height:500px;overflow-y:auto;" id="authList">
            <input type="hidden" name="roleId" value="{$roleId}" id="roleId" />
            <div class="modal-body" id="authDiv">
                <volist name="authList" id="vo">
                    <div class="auths">
                        <div class="col-sm-12 col-md-12 col-lg-12">
                            <input type="checkbox" id="checkbox_{$vo.id}" <if condition="in_array($vo['id'],$checkList)">checked="checked"</if> autoCheck="true" class="oneAuth" value="{$vo.id}" name="auths[]" />

                            <label for="checkbox_{$vo.id}">{$vo.todo}</label>
                        </div>
                        <div class="subAuths col-sm-12 col-md-12 col-lg-12">
                            <volist name="vo['subAuths']" id="v">
                                <span class="col-sm-3 col-md-3 col-lg-3">
                                    <input thisPid="checkbox_{$vo.id}" type="checkbox" id="checkbox_{$v.id}" <if condition="in_array($v['id'],$checkList)">checked="checked"</if> class="oneAuth" value="{$v.id}" name="auths[]" />
                                    <label for="checkbox_{$v.id}" title="{$v.todo}">{$v.todo|msubstr=###,0,8,"utf-8",true}</label>

                                </span>
                            </volist>
                        </div>
                    </div>
                </volist>
            </div>
        </form>
        <div class="modal-footer">
            <button type="button" data-dismiss="modal" class="btn btn-default">取消</button>
            <button type="button" id="modalSave" class="btn btn-primary">保存</button>
        </div>
    </div>
</div>
<script>


    $("input[type='checkbox']").iCheck({
        checkboxClass: 'icheckbox_flat-blue',
        radioClass: 'iradio_flat-blue',
        increaseArea: '10%'
    });



    $("input[type='checkbox']").on('ifChecked', function (event) {
        $("input:checkbox[thisPid='" + event.target.id + "']").iCheck('check');
    })

    $("input[type='checkbox']").on('ifUnchecked', function (event) {
        $("input:checkbox[thisPid='" + event.target.id + "']").iCheck('uncheck');
    })

    $("#modalSave").click(function () {
        $.ajax({
            url: "{:U('Admin/Role/setAuths')}",
            type: "post",
            dataType: "json",
            data: $("#authList").serialize(),
            success: function (data) {
                //console.log(data);
                closeModel();
            }
        })
    })
    function closeModel() {
        $("#commonModal").modal('toggle');
    }






</script>